<template>
    <div class="company-info" v-loading="loading">
        <DescribeSpecCom class="mb20 mt20" :list="formList" :form="form" />
        <el-collapse accordion v-model="activeNames" @change="handleChange">
            <el-collapse-item v-for="(v, k) in tableObj" :key="k" :name="k">
                <template #title>
                    <div> {{ v.label }}
                        <span class="ml5" style="color:red">
                            {{ form[v.prop1]?.num || 0 }}
                        </span>
                        <span style="color:#283de6;margin-left: 2px;">{{ v.unit || '条' }}</span>
                    </div>
                </template>
                <tableCom :columns="v.children" :dataList="getDataList(v) || []" :key="activeTab" />
            </el-collapse-item>
        </el-collapse>
    </div>
</template>

<script setup>
import { getEnterpriseInfo } from '@/api/taxReportManage';
import tableCom from '../components/tableCom';
import DescribeSpecCom from '../components/describeSpecCom.vue';
const route = useRoute()
const form = ref({
    shareholderCase: {},
    shareholderChangeInfoCase: {},
    lawsuiInfotInfo: {},
    bankTaxInteractiveInfoRecord: {},
    bankTaxReportInfoCase: {},
})
const loading = ref(false)
const activeNames = ref(null)
const formList = ref([
    { label: '企业名称', prop: 'name', },
    { label: '识别税号', prop: 'taxpayerId', len: 20 },
    { label: '法人姓名', prop: 'legalName', },
    { label: '法人年龄', prop: 'legalAge', },
    { label: '法人股权', prop: 'sharepctLegalpers', unit: '%', },
    { label: '成立日期', prop: 'startDate', },
    { label: '行业类型', prop: 'industryType' },
    { label: '注册类型', prop: 'organizationType' },
    { label: '注册地址', prop: 'registerAddress', len: 12 },
    { label: '经营范围', prop: 'scope', class: 'two-line' },
])
const tableObj = {
    0: {
        label: '股东情况',
        prop1: 'shareholderCase',
        prop2: 'shareholderList',
        children: [
            { label: '股东名称', prop: 'name' },
            { label: '持股比例', prop: 'sharesRate', isRed: 'isRed' },
            { label: '认缴出资额', prop: 'sharesAmount' },
            { label: '股东年龄', prop: 'sharesAge' },
            { label: '入股日期', prop: 'joinTime' },
            { label: '持股时间', prop: 'sharesNum' },
        ],
    },
    1: {
        label: '股东变动情况',
        prop1: 'shareholderChangeInfoCase',
        prop2: 'shareholderChangeInfoList',
        children: [
            { label: '投资人类型', prop: 'stockType', width: 140 },
            { label: '变更类型', prop: 'changeType' , width: 140 },
            { label: '变更时间', prop: 'changeDate', width: 120  },
            { label: '变更前占股比例', prop: 'changeBefore', isRed: 'isRed' },
            { label: '变更后占股比例', prop: 'changeAfter', isRed: 'isRed' },
            { label: '股东名称', prop: 'stockName' },
            { label: '变更项目', prop: 'projectName' },
        ],
    },
    2: {
        label: '企业司法情况',
        prop1: 'lawsuiInfotInfo',
        prop2: 'lawsuiInfotViewModels',
        children: [
            { label: '开庭时间', prop: 'holdDate' },
            { label: '案由', prop: 'reason' },
            { label: '案号', prop: 'caseNo', isRed: 'isRed' },
            { label: '被上诉人', prop: 'defendantList' },
            { label: '结束日期', prop: 'finishDate' },
            { label: '案件状态', prop: 'caseStatus' },
            { label: '案件类型', prop: 'caseType' },
            { label: '法院', prop: 'court' },
            { label: '立案日期', prop: 'publishDate' },
            { label: '上诉人', prop: 'prosecutorList' },
        ],
    },
    3: {
        label: '银行授信互动信息记录',
        prop1: 'bankTaxInteractiveInfoRecord',
        prop2: 'bankTaxInteractiveInfos',
        children: [
            { label: '申报日期', prop: 'declarationDate' },
            { label: '产品名称', prop: 'bankProduct' },
            { label: '授信额度', prop: 'applicationAmount', isRed: 'isRed' },
            { label: '贷款余额', prop: 'loanBalance' },
            { label: '银行名称', prop: 'bankName' },
            { label: '贷款金额', prop: 'loanAmount' },
            { label: '状态', prop: 'state' },
        ]
    },
    4: {
        label: '银税报告',
        prop1: 'bankTaxReportInfoCase',
        prop2: 'bankTaxReportInfos',
        children: [
            { label: '查看次数', prop: 'queryNum', len: 30 },
            { label: '查看人数', prop: 'personNum', len: 30 },
            { label: '订阅端口', prop: 'subPort', len: 30 },
            { label: '采集时间', prop: 'addTime', len: 30 },
        ]
    },
}
getInfo()
function getInfo() {
    const reqForm = { id: route.query.id }
    loading.value = true
    getEnterpriseInfo(reqForm).then(res => {
        form.value = res.data
    }).finally(() => loading.value = false)
}

function getDataList(row) {
    return form.value[row.prop1] ? form.value[row.prop1][row.prop2] : []
}
</script>

<style lang="scss" scoped>
:deep .el-collapse-item__content {
    padding-bottom: 0;
}
</style>
<style lang="scss">
.company-info {
    .describe-com .el-descriptions__label {
        width: 100px !important;
    }
}
</style>